package cn.wizzer.app.web.modules.controllers.crown;

import cn.wizzer.app.sys.modules.services.SysMsgService;
import cn.wizzer.app.sys.modules.services.SysParamService;
import cn.wizzer.app.web.commons.filter.ApiTokenFilter;
import cn.wizzer.framework.base.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;


/**
 * 皇冠公告Controller
 *
 * @author
 */
@At("/api/match/hg/msg")
@IocBean
@Filters({@By(type = ApiTokenFilter.class)})
public class ApiCrownMsgController {


    @Reference
    @Inject
    private SysMsgService sysMsgService;

    @Reference
    @Inject
    private SysParamService sysParamService;

    /**
     * 皇冠公告
     *
     * @return
     */
    @At()
    @Ok("json")
    @Filters(@By(type = ApiTokenFilter.class))
    public Result list() {
        if (!sysParamService.fetch().getGameSwitch()) {
            // 前端大佬要code=0，data为false。
            return Result.success(false);
        }
        return Result.success().addData(sysMsgService.query(
                Cnd.where("delFlag", "=", 0)
                        .and("type", "=", "crownAll ")));
    }

}





